<!--
 * @Description: 特材运输清单
 * @Author: wangwangwang
 * @Date: 2020-09-21 14:09:06
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2021-12-29 15:03:28
-->
<template>
  <div class="pages_content table">
    <el-container>
      <el-header>
        <breaDcrumb />
      </el-header>
      <el-main style="display: flex">
        <div style="width:100%;">
          <div class="header_right" @click="showCardNav = !showCardNav">
            <div class="title">搜索</div>
            <div>
              <transition name="from"></transition>
              <span v-show="!showCardNav">
                <i style="margin-right: 5px" class="el-icon-arrow-down"></i>
              </span>
              <transition name="to"></transition>
              <span v-show="showCardNav">
                <i style="margin-right: 5px" class="el-icon-arrow-up"></i>
              </span>
            </div>
          </div>
          <div v-show="showCardNav" class="hr"></div>
          <el-collapse-transition>
            <div v-show="showCardNav">
              <div class="search">
                <span style="display: inline-block;margin-bottom: 10px;" placeholder="请选择">
                  <span style="margin-right: 12px">站点</span>
                  <el-cascader ref="stationIdList" v-model="stationIdList" :options="siteIdListTree" :show-all-levels="false" @change="tableParam.stationId  = $refs.stationIdList.getCheckedNodes()[0].value"></el-cascader>
                </span>
                <span style="margin-left: 24px">
                  <span style="margin-right: 12px">司机</span>
                  <el-input v-model="tableParam.driver" style="width: 240px" clearable placeholder="请输入" @keyup.enter.native="gettableData()" />
                </span>
                <span style="margin-left: 24px">
                  <span style="margin-right: 12px">车牌号</span>
                  <el-input v-model="tableParam.carNo" style="width: 240px" clearable placeholder="请输入" @keyup.enter.native="gettableData()" />
                </span>
                <el-button icon="el-icon-search" size="medium" class="bottom_all" @click="(tableParam.page = 1), gettableData()">查 询</el-button>
                <el-button size="medium" class="bottom_all_two" style="margin-left: 12px" @click="init()">重 置</el-button>
              </div>
            </div>
          </el-collapse-transition>
          <div class="hr"></div>
          <div class="card" style="padding-top:10px">
            <div v-loading="tableLoading" class="card_info">
              <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width: 100%" :data="tableData" tooltip-effect="dark">
                <template v-for="(item, index2) in table">
                  <el-table-column v-if="item.status" :key="index2" :label="item.label" align="center" :width="item.width">
                    <template slot-scope="scope">
                      <span v-if="item.label == '状态'">
                        <span v-if="scope.row.dataStatus==0">待出货</span>
                        <span v-else-if="scope.row.dataStatus==1">待收货</span>
                        <span v-else-if="scope.row.dataStatus==2">已收货</span>
                        <span v-else-if="scope.row.dataStatus==3">已完成</span>
                      </span>
                      <span v-else>{{ scope.row[item.prop] }}</span>
                    </template>
                  </el-table-column>
                </template>
              </el-table>
            </div>
            <div class="card_bottom">
              <div class="card_bottom_left">
                <div class="top_page_totle">总共{{ total }}条</div>
                <el-pagination :current-page.sync="tableParam.page" :page-size="tableParam.pageSize" :page-sizes="[10, 20, 30, 40,50,100,200,500,1000]" layout="prev,pager,sizes,next,jumper" :total="total" @size-change="sizeChange" @current-change="gettableData()"></el-pagination>
              </div>
              <div>
                <el-button size="mini" icon="el-icon-refresh-right" class="bottom_all_two" @click="gettableData">刷新</el-button>
              </div>
            </div>
          </div>
        </div>
      </el-main>
    </el-container>
  </div>
</template>

<script>
import mixin from "@/mixins/ICPSmixin.js";
import {
  queryPage,
} from "@/api/smart/specialmaterial/shiplist.js";
import { getUserAutList } from "@/api/common.js";
export default {
  mixins: [mixin],
  data() {
    return {
      stationIdList: [],
      siteIdListTree: [],
      /*表格增删改查及下载接口*/
      queryPage: queryPage,
      pagesType: 0,
      /*表格数据*/
      table: [
        {
          label: "运输编号",
          width: "auto",
          prop: "code",
          status: true,
        },
        { label: "站点", width: "auto", prop: "station", status: true },
        {
          label: "特材成品名称",
          width: "auto",
          prop: "productName",
          status: true,
        },
        { label: "成品型号", width: "auto", prop: "productType", status: true },
        { label: "需求量", width: "120", prop: "needNum", status: true },
        { label: "出货量", width: "120", prop: "shipment", status: true },
        { label: "第一次过磅量", width: "120", prop: "firstWeighing", status: true },
        { label: "第二次过磅量", width: "120", prop: "secondWeighing", status: true },
        { label: "收货量", width: "120", prop: "recNum", status: true },
        { label: "入库量", width: "120", prop: "receipt", status: true },
        { label: "需求时间", width: "120", prop: "needTime", status: true },
        { label: "计划交货时间", width: "120", prop: "planTime", status: true },
        { label: "司机", width: "120", prop: "driver", status: true },
        { label: "车牌号", width: "120", prop: "carNo", status: true },
        { label: "状态", width: "120", prop: "dataStatus", status: true },
      ],
    };
  },
  async created() {
    this.siteIdListTree = await getUserAutList()
    this.tableParam = {
      ...this.tableParam, dataType: 1
    };
    this.gettableData();
  },
  methods: {
    /*重置数据*/
    init() {
      this.stationIdList = []
      this.tableParam.stationId = "";
      this.tableParam.driver = "";
      this.tableParam.carNo = "";
      this.gettableData();
    },
    sizeChange(value) {
      this.tableParam.pageSize = value;
      this.gettableData();
    },
  },
};
</script>
